<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.w3.org/1999/xhtml">
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8"/>
    <title>分页通用页面</title>
</head>
<body>
<!--<div class=" float-none float-sm-right ">-->
    <!--<nav aria-label="Page navigation example" >-->
        <!--<ul class="pagination">-->
            <!--<li class="page-item"><a class="page-link" href="#">&laquo;</a></li>-->
            <!--<li class="page-item"><a class="page-link" href="#">1</a></li>-->
            <!--<li class="page-item"><a class="page-link" href="#">2</a></li>-->
            <!--<li class="page-item"><a class="page-link" href="#">3</a></li>-->
            <!--<li class="page-item"><a class="page-link" href="#">&raquo;</a></li>-->
        <!--</ul>-->
    <!--</nav>-->
<!--</div>-->

<!--当前页 ，总页数 ，地址 ，参数 -->
<th:block th:fragment="page(current, pages, url, urlPara)">
    <div class=" float-none float-sm-right ">
        <ul class="pagination">
            <!--<li class="page-item">-->
                <!--<a th:href="@{${url} + '&' + ${urlPara} + '= 1 '}" class="page-link ">首页</a>-->
            <!--</li>-->
            <li class="page-item">
                <a th:if="${current>1}" class="page-link " th:href="@{${url} + '&' + ${urlPara} + '=' + ${current - 1}}">&laquo;</a>
            </li>
            <li class="page-item">
             <a th:if="${current==1}" class="page-link " disabled>&laquo;</a>
            </li>
            <th:block th:if="${ pages <= 5 && pages > 0}" th:each="i: ${#numbers.sequence(1, pages)}">
                <li class="page-item" th:classappend="${current == i} ? ' active'" >
                <a class="page-link "
                   th:href="@{${url} + '&'  + ${urlPara} + '=' + ${i}}" th:text="${i}"></a>
                </li>
            </th:block>
            <th:block th:if="${current<3 && pages > 5 && current != pages}" th:each="i: ${#numbers.sequence(1, 5)}">
                <li class="page-item" th:classappend="${current == i} ? ' active'">
                <a class="page-link "
                   th:href="@{${url} + '&'  + ${urlPara} + '=' + ${i}}" th:text="${i}"></a>
                </li>
            </th:block>

            <th:block th:if="${current >=3 && current +2 <= pages && pages > 5&& current != pages}"
                      th:each="i: ${#numbers.sequence(current - 2,current +2)}">
                <li class="page-item" th:classappend="${current == i} ? ' active '" >
                    <a class="page-link "
                       th:href="@{${url} + '&'  + ${urlPara} + '=' + ${i}}" th:text="${i}"></a>
                </li>
            </th:block>

            <th:block th:if="${current +2 > pages && pages > 5 }" th:each="i: ${#numbers.sequence(pages - 4,pages)}">
                <li class="page-item" th:classappend="${current == i} ? ' active '">
                <a class="page-link "
                   th:href="@{${url} + '&'  + ${urlPara} + '=' + ${i}}" th:text="${i}"></a>
                </li>
            </th:block>
            <li class="page-item">
            <a th:if="${current} == ${pages}" class="page-link " disabled>&raquo;</a>
            </li>
            <li class="page-item ">
            <a th:if="${current} < ${pages}" class="page-link "
               th:href="@{${url} + '&' + ${urlPara} + '=' + ${current + 1}}">&raquo;</a>
            </li>
            <!--<li class="page-item">-->
            <!--<a th:if ="${pages>0} "th:href="@{${url} + '&' + ${urlPara} + '='+ ${pages}}" class="page-link">末页</a>-->
            <!--</li>-->
            <li class="page-item">
            <a th:if="${pages == 0}" class="page-link " disabled>&raquo;</a>
            </li>
            <!--<li class="page-item">-->
            <!--<a th:if ="${pages == 0} " class="page-link " disabled>末页</a>-->
            <!--</li>-->
        </ul>
    </div>
</th:block>
</body>
</html>